package com.ruoyi.dispatch.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dispatch.domain.DrivingTeam;
import com.ruoyi.dispatch.service.IDrivingTeamService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 开掘队信息Controller
 * 
 * @author wuxiaofang
 * @date 2025-04-08
 */
@RestController
@RequestMapping("/dispatch/drivingTeam")
@Anonymous
public class DrivingTeamController extends BaseController
{
    @Autowired
    private IDrivingTeamService drivingTeamService;

    /**
     * 查询开掘队信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:drivingTeam:list')")
    @GetMapping("/list")
    public TableDataInfo list(DrivingTeam drivingTeam)
    {
        startPage();
        List<DrivingTeam> list = drivingTeamService.selectDrivingTeamList(drivingTeam);
        return getDataTable(list);
    }

    /**
     * 导出开掘队信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:drivingTeam:export')")
    @Log(title = "开掘队信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DrivingTeam drivingTeam)
    {
        List<DrivingTeam> list = drivingTeamService.selectDrivingTeamList(drivingTeam);
        ExcelUtil<DrivingTeam> util = new ExcelUtil<DrivingTeam>(DrivingTeam.class);
        util.exportExcel(response, list, "开掘队信息数据");
    }

    /**
     * 获取开掘队信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:drivingTeam:query')")
    @GetMapping(value = "/{drivingTeamId}")
    public AjaxResult getInfo(@PathVariable("drivingTeamId") Long drivingTeamId)
    {
        return success(drivingTeamService.selectDrivingTeamByDrivingTeamId(drivingTeamId));
    }

    /**
     * 新增开掘队信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:drivingTeam:add')")
    @Log(title = "开掘队信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DrivingTeam drivingTeam)
    {
        drivingTeam.setCreateBy(getUsername());
        return toAjax(drivingTeamService.insertDrivingTeam(drivingTeam));
    }

    /**
     * 修改开掘队信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:drivingTeam:edit')")
    @Log(title = "开掘队信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DrivingTeam drivingTeam)
    {
        drivingTeam.setUpdateBy(getUsername());
        return toAjax(drivingTeamService.updateDrivingTeam(drivingTeam));
    }

    /**
     * 删除开掘队信息
     */
   // @PreAuthorize("@ss.hasPermi('dispatch:drivingTeam:remove')")
    @Log(title = "开掘队信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{drivingTeamIds}")
    public AjaxResult remove(@PathVariable Long[] drivingTeamIds)
    {
        return toAjax(drivingTeamService.deleteDrivingTeamByDrivingTeamIds(drivingTeamIds));
    }
}
